﻿using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Lamex.SIESystemManager.Calculate
{
    public class C_D44
    {
        public double GetD44(DataRow[] dr1, DataRow[] dr2)
        {
            double TD44 = 0;
            string D44_Barrel_Type = "";
            double D44_Drawers_Qty = 0;
            //单位工时
            double WD44_Drawers_Qty = 0;
            //附加工时
            double AD44_Drawers_Qty = 0;
            //获取数据库每个工序动作的单位工时和附加工时
            foreach (var drHours in dr2)
            {
                switch (drHours["OPERATIONAL_NAME"].ToString())
                {
                    case "装抽屉数量":
                        WD44_Drawers_Qty = double.Parse(string.IsNullOrEmpty(drHours["UNIT_WORKHOURS"].ToString()) ? "0" : drHours["UNIT_WORKHOURS"].ToString());//单位工时
                        AD44_Drawers_Qty = double.Parse(string.IsNullOrEmpty(drHours["ATTACH_WORKHOURS"].ToString()) ? "0" : drHours["ATTACH_WORKHOURS"].ToString());//附加工时
                        break;
                }
            }
            //特征值
            foreach (var drData in dr1)
            {
                D44_Barrel_Type = drData["D44_Barrel_Type"].ToString();
                D44_Drawers_Qty = double.Parse(string.IsNullOrEmpty(drData["D44_Drawers_Qty"].ToString()) ? "0" : drData["D44_Drawers_Qty"].ToString());
            }
            //工时计算
            if (D44_Drawers_Qty<4)
            {
                if (D44_Barrel_Type == "胶抽")
                {
                    if (D44_Drawers_Qty == 2)
                        TD44 = 960;
                    if (D44_Drawers_Qty == 3)
                        TD44 = 1140;
                }
                if (D44_Barrel_Type == "木抽")
                {
                    if (D44_Drawers_Qty == 2)
                        TD44 = 1400;
                    if (D44_Drawers_Qty == 3)
                        TD44 = 1800;
                }
            }
            //else
            //{
            //    if (D44_Barrel_Type == "胶抽")
            //    {
            //        TD44 = 1140 + (D44_Drawers_Qty-3) * WD44_Drawers_Qty * 2;
            //    }
            //    if (D44_Barrel_Type == "木抽")
            //    {
            //        TD44 = 1510 + (D44_Drawers_Qty-3) * WD44_Drawers_Qty * 2;
            //    }
            //}
            return TD44;
        }
    }
}
